import 'package:flutter/material.dart';
import 'package:flutter_common/ui/web_view.dart';
import 'package:flutter_common/ui/widget/button.dart';
import 'package:flutter_common/ui/widget/skeleton.dart';
import 'package:flutter_common/util/context_extension.dart';

class ButtonDemo extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text("button demo"),
        ),
        body: build2()
    );
  }

  Widget build2() {
    return FutureBuilder(
      future: _dd(),
        initialData: 0,
        builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
        switch(snapshot.connectionState) {
          case ConnectionState.done :
            {
              return SingleChildScrollView(
                  child: Column(
                    children: [
                      FxElevatedButton("text", onPressed: () {
                        print("text");
                      }, margin: const EdgeInsets.all(10),),
                      FxOutlinedButton("text", onPressed: () {
                        print("text outline");
                      }),
                      Container(height: 5,),
                      FxElevatedButton(
                        "text", onPressed: () {}, borderRadius: 10,),
                      FxElevatedButton("full button", full: true,
                          onPressed: () {},
                          margin: const EdgeInsets.all(20)),
                      FxOutlinedButton(
                          "web view button", full: true, onPressed: () {
                            setWebContentsDebuggingEnabled(true);
                            context.push(SimpleWebView(url: 'https://uat-tianxin.ezcun.com/admin/?version=1.0.35#/signH5Notice?orderId=10630'));
                      }),
                      Container(height: 15,),
                      FxOutlinedButton("text", disabled: true,),
                      Container(height: 15,),
                      FxElevatedButton(
                        "text", disabled: true, borderRadius: 10,),
                      TextButton(
                          onPressed: () {}, child: Icon(Icons.construction)),
                    ],
                  ));
            }
          case ConnectionState.none:
          case ConnectionState.waiting:
          case ConnectionState.active:
            return const LoadingSkeleton();
        }
    });
  }
  Future<int> _dd() {
    return Future.delayed(const Duration(milliseconds: 500)).then((value) => 1);
  }
}
